package com.zxx.otherchaos.widgets.rvtouch;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.util.Log;

import com.zxx.otherchaos.R;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class RvTouchActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rv_touch);

        setRVItem();
    }

    private void setRVItem() {
        RecyclerView recyclerView = findViewById(R.id.recycler_view);
        final List<String> list = new ArrayList<>();
        for (int i = 0; i < 50; i++) {
            list.add("Pos:" + i);
        }
        final ItemRvAdapter adapter = new ItemRvAdapter(list);
//        GridLayoutManager manager = new GridLayoutManager(this, 3);
                LinearLayoutManager manager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(manager);
        recyclerView.setAdapter(adapter);
        //recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.HORIZONTAL));

        ItemTouchHelperCallback callback = new ItemTouchHelperCallback(adapter);
        ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
        touchHelper.attachToRecyclerView(recyclerView);
    }
}